package org.itboys.mobile.controller.web;


import org.itboys.commons.CommonConstants;
import org.itboys.commons.utils.ajax.AjaxUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.mobile.service.SundayAlertService;
import org.itboys.mobile.util.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;



/**
 * 
 * 作者：jiangxiong
 * 日期：2016年11月7日
 * 联系方式 ：empty90911@126.com
 * 描述：圣代_提醒_后台
 */
@Controller
@RequestMapping("/sunday/web/alert")
public class TianJieAlertController extends BaseController {
	@Autowired
	private SundayAlertService alertService;

	/**
	 * 获取后台需要提醒的数据
	 * @param request
	 * @param response
	 */
	@RequestMapping(value="/getAlertInfo", method=RequestMethod.POST)
	public void getAlertInfo(HttpServletRequest request,
			HttpServletResponse response){
		try {
			Map<String,Integer> result = alertService.getAlertInfo();
			ResponseMessage.success(result);
		} catch (Exception e) {
			String msg ="";
			if(e.getClass().getSimpleName().equalsIgnoreCase("ErrorException")){
				msg=e.getMessage();
			}else{
				msg= CommonConstants.ERROMSG;
				logger.error("/sunday/web/alert/getAlertInfo------"+e.getMessage());
			}
			e.printStackTrace();
			ResponseMessage.error(CommonConstants.FAIL_CODE, msg);
		}
	}
	
}
